package com.qf.encryptiondemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;

public class Base64Activity extends AppCompatActivity {

    private String data = "八千里路云和月，莫等闲白了少年头";
    private String data1 = "5YWr5Y2D6YeM6Lev5LqR5ZKM5pyI77yM6I6r562J6Zey55m95LqG5bCR5bm05aS0";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base64);

        //直接调用类即可
        byte[] encode = Base64.encode(data.getBytes(), Base64.DEFAULT);
        Log.d("flag", "---------->onCreate: 使用Base64编码的内容是：" +new String(encode));


        //解码
        byte[] decode = Base64.decode(data1.getBytes(), Base64.DEFAULT);
        Log.d("flag", "---------->onCreate: 使用Base64解码的内容是：" +new String(decode));
    }
}
